package com.shxc.smarttrade.old.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.shxc.smarttrade.R;
import com.shxc.smarttrade.old.bean.Broker;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by jcdev1 on 2017/7/24.
 */

public class BrokerAdapter extends BaseAdapter {
    private Context mContext;
    private List<Broker> brokerList;

    public BrokerAdapter(Context mContext, List<Broker> brokerList) {
        this.mContext = mContext;
        this.brokerList = brokerList;

    }

    @Override
    public int getCount() {
        return brokerList == null ? 0 : brokerList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Broker broker = brokerList.get(position);
        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        convertView = layoutInflater.inflate(R.layout.adapter_broker, null);
        AutoUtils.autoSize(convertView);

        if (convertView != null) {
            ImageView imageView = (ImageView) convertView.findViewById(R.id.iv_picture);
            TextView tvName = (TextView) convertView.findViewById(R.id.tv_name);
            TextView tvStatus = (TextView) convertView.findViewById(R.id.tv_status);
            imageView.setImageResource(broker.getPicture());
            tvName.setText(broker.getName());
            tvStatus.setText(broker.getStatus());
        }
        return convertView;
    }
}
